<?php

namespace app\common\model\mycurrency;

use think\Exception;
use think\Model;
use traits\model\SoftDelete;

class LeaseStrategy extends Model
{

    //use SoftDelete;

    // 表名
    protected $name = 'mycurrency_lease_strategy';

    // 追加属性
    protected $append = [
        'charge_text'
    ];

    const TYPES_SHICHANG = 1;//策略类型 = 按时长计费
    const TYPES_CISHU = 2;//策略类型 = 按次数计费
    const TYPES_TAOCAN = 3;//策略类型 = 按套餐计费

    const PACKAGE_TYPES_FENZHONG = 1;//套餐时长类型:1=分钟
    const PACKAGE_TYPES_XIAOSHI = 2;//套餐时长类型:2=小时
    const PACKAGE_TYPES_TIAN = 3;//套餐时长类型:3=天

    const STATUS_ZHENGCHENG = 1;//状态 = 正常
    const STATUS_JINYONG = 2;//状态 = 禁用


    public function getChargeTextAttr($value, $data)
    {
        $str = '';
        if($data['types'] == self::TYPES_SHICHANG){//策略类型 = 按时长计费
            $str = "{$data['unit_price']}元/{$data['duration']}分钟";
        }elseif ($data['types'] == self::TYPES_CISHU){//策略类型 = 按次数计费
            $str = "{$data['unit_price']}元/次";
        }elseif ($data['types'] == self::TYPES_TAOCAN){
            $str = "根据选择套餐计费";
        }
        return $str;
    }


}
